/* 
 * File:   Character.h
 * Author: paula
 *
 * Created on 8 de septiembre de 2014, 23:26
 */

#ifndef CHARACTER_H
#define	CHARACTER_H


#include "../Define/DefaultValues.h"
#include <string>
#include <SDL2/SDL.h>
#include <SDL2/SDL_image.h>
#include "Object.h"
#include "ObjFactory.h"
#include "Dot.h"
#include "SBSImage.h"

using namespace std;

class Character {
public:

    Character();
    Character(ObjFactory *objFactory, int x, int y);
    Character(const Character& orig);
    virtual ~Character();

    void wait();
    void walkRight();
    void walkLeft();
//    void walkRight(float velocityX);
//    void walkLeft(float velocityX);
    void jump();
    void kneel();

    bool isJumping();
    bool isKneeling();
    bool isFallingDown();
    bool isWalking();
    bool isWalkingRight();
    bool isWalkingLeft();

    void keepJumping();
    void keepKneeling();
    void keepFallingDown();
    void keepWalking();

    void fallRight();
    void fallLeft();
    void jumpingRight();
    void jumpingLeft();
    void stopWalking();

    int getState();

private:

    Dot *dot;
    SDL_Renderer* gRenderer;

    SBSImage* principalR;
    SBSImage* principalR0;
    SBSImage* principalR1;
    SBSImage* principalR2;
    SBSImage* principalR3;
    SBSImage* principalR4;
    SBSImage* principalL;
    SBSImage* principalL0;
    SBSImage* principalL1;
    SBSImage* principalL2;
    SBSImage* principalL3;
    SBSImage* principalL4;
    SBSImage* principalDL1;
    SBSImage* principalDL2;
    SBSImage* principalDL3;
    SBSImage* principalDR1;
    SBSImage* principalDR2;
    SBSImage* principalDR3;
    SBSImage* principalUL1;
    SBSImage* principalUL2;
    SBSImage* principalUL3;
    SBSImage* principalUR1;
    SBSImage* principalUR2;
    SBSImage* principalUR3;

    bool directionRight;
    bool wasJumping;
    bool beginning;
    bool jumping, kneeling, fallingDown, walking;
    int counterRight, counterLeft, counterRightII, counterLeftII, counterKneel, counterJump, counterWait;
    int delayWalk,delay;
    float windowPixelWidth, windowPixelHeight, windowUnitWidth, windowUnitHeight; 
    float lastPosY, currentPosY, lastVelY, currentVelY;
    float objWidth, objHeight;
    Object* object;
    ObjFactory *objFactory;
    SBSLog* myLogFile;
    
    float constFall;
    float initConsFall;
    
    float velocityWalkLeft;
    float velocityWalkRight;
    
    bool characterOverlap(int x, int y);

    void jumpRight();
    void jumpLeft();
    void moveRight(float velocityX, float velocityY);
    void moveLeft(float velocityX, float velocityY);

    void loadMedia();
    void changeImage(SBSImage* image, int delay);
    void actualizePosition();
    void close();

};

#endif	/* CHARACTER_H */